# -*- coding:utf-8 -*-
# @Author: shenyuyu
# @Time: 2023/6/26 11:36
# @File: qu_8_saveAsTextFile.py
from pyspark import SparkConf, SparkContext
from operator import add

if __name__ == '__main__':
    conf = SparkConf().setAppName("test").setMaster("local[*]")
    sc = SparkContext(conf=conf)

    rdd = sc.parallelize([1, 2, 3, 4, 5, 6], 2)

    # 写本地
    # rdd.saveAsTextFile("file:///tmp/pycharm_project_158/out/data.txt")

    # 写到hdfs 这个算子也是由executor之间运行
    rdd.saveAsTextFile("hdfs://hadoop1:9820/output")